<template>
  <view class="action-bar">
    <view class="action-icons">
      <view class="action-icon" @click="navigateTo('/pages/cart/index')">
        <uni-icons type="cart" size="24" color="#666"></uni-icons>
        <text>购物车</text>
      </view>
      <view class="action-icon" @click="navigateTo('/pages/user/index')">
        <uni-icons type="person" size="24" color="#666"></uni-icons>
        <text>我的</text>
      </view>
    </view>
    
    <view class="action-buttons">
      <view class="btn-add-cart" @click="$emit('add-to-cart')">加入购物车</view>
      <view class="btn-buy-now" @click="$emit('buy-now')">立即购买</view>
    </view>
  </view>
</template>

<script setup>
const navigateTo = (url) => {
  uni.switchTab({ url })
}
</script>

<style lang="scss">
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100rpx;
  display: flex;
  background-color: $white-bg;;
  border-top: 1rpx solid #f5f5f5;
  z-index: 100;
  
  .action-icons {
    display: flex;
    width: 30%;
    
    .action-icon {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: 22rpx;
      color: $text-color-666;
      
      text {
        margin-top: 6rpx;
      }
    }
  }
  
  .action-buttons {
    display: flex;
    width: 70%;
    
    view {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: $font-size-28rpx;
    }
    
    .btn-add-cart {
      background-color: $secondary-color;
      color: $text-color-inverse;
    }
    
    .btn-buy-now {
      background-color: $primary-color;
      color: $text-color-inverse;
    }
  }
}
</style>